import request from '@/utils/request'

interface IResponseType<P = {}> {
  token: string;
  refresh_token: string;
  data?: P;
}
interface ILogin {
  // token: string;
  // expires: number;
}
interface FormType {
  phone: string;
  password: string;
}

interface sendMsgType {
  phone: string;
}

interface registerType extends FormType {
  sms: string;
}

export function login(data: FormType) {
  return request<IResponseType<ILogin>>({
    url: '/login',
    headers: {
      isToken: false
    },
    method: 'post',
    data
  })
}

export function register(data: registerType) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data
  })
}

export function sendMsgCode(data: sendMsgType) {
  return request({
    url: '/sendMsgCode',
    headers: {
      isToken: false
    },
    method: 'get',
    params: data
  })
}